<div class="boxed">
    <div id="content-container">
        <div id="page-title">
            <h1 class="page-header text-overflow">Data Tables</h1>
            <div class="searchbox">
                <div class="input-group custom-search-form">
                    <input type="text" class="form-control" placeholder="Search..">
                    <span class="input-group-btn">
                        <button class="text-muted" type="button"><i class="demo-pli-magnifi-glass"></i></button>
                    </span>
                </div>
            </div>
        </div>
        <ol class="breadcrumb">
            <li><a href="{:url('Admin/Index/index')}">首页</a></li>
            <li><a href="#">权限控制</a></li>
            <li class="active">分配权限</li>
        </ol>
        <div class="panel">
            <div id="demo-panel-w-alert" class="panel">
                <!--Panel heading-->
                <div class="panel-heading">
                    <div class="panel-control">
                        <i class="fa fa-thumbs-o-up fa-lg fa-fw"></i>
                        <span class="badge badge-pink">7</span>
                        <span class="label label-purple">Label</span>
                    </div>
                    <h3 class="panel-title">
                        <button id="demo-panel-alert" class="btn btn-primary"> {$group_data['title']}</button>
                    </h3>
                </div>
                <div class="panel-alert"></div>
                <!--Panel body-->
                <div class="panel-body">
                    <form action="" method="post">
                        <input type="hidden" name="id" value="{$group_data['id']}">
                        <table class="table table-striped table-bordered table-hover table-condensed">
                            {foreach name="rule_data" id="v"}
                            {empty name="v['_data']"}
                            <tr class="b-group">
                                <th width="10%">
                                    <label>
                                        {$v['title']}
                                        <input type="checkbox" name="rule_ids[]"
                                               value="{$v['id']}" {if condition="in_array($v['id'],$group_data['rules'])"}    checked="checked"{/if} onclick="checkAll(this)" >
                                    </label>
                                </th>
                                <td></td>
                            </tr>
                            {else /}
                            <tr class="b-group">
                                <th width="10%">
                                    <label>
                                        {$v['title']} <input type="checkbox" name="rule_ids[]" value="{$v['id']}" {if condition="in_array($v['id'],$group_data['rules'])"}  checked="checked"{/if} onclick="checkAll(this)">
                                    </label>
                                </th>
                                <td class="b-child">
                                    {foreach name="v['_data']" id="n"}
                                    <table class="table table-striped table-bordered table-hover table-condensed">
                                        <tr class="b-group">
                                            <th width="15%">
                                                <label>
                                                    {$n['title']} <input type="checkbox" name="rule_ids[]" value="{$n['id']}" {if condition="in_array($n['id'],$group_data['rules'])"}  checked="checked"{/if} onclick="checkAll(this)">
                                                </label>
                                            </th>
                                            <td>
                                                {notempty name="n['_data']"}
                                                {volist name="n['_data']" id="c"}
                                                <label>
                                                    &emsp;{$c['title']} <input type="checkbox" name="rule_ids[]" value="{$c['id']}" {if condition="in_array($c['id'],$group_data['rules'])"}    checked="checked"{/if} >
                                                </label>
                                                {/volist}
                                                {/notempty}
                                            </td>
                                        </tr>
                                    </table>
                                    {/foreach}
                                </td>
                            </tr>
                            {/empty}
                            {/foreach}
                            <tr>
                                <td colspan="2" style="text-align: center">
                                    <button id="demo-panel-alert" class="btn btn-success" type="submit">修改权限</button>
                                    <button id="demo-panel-alert2" class="btn btn-default">取消</button>
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function checkAll(obj){
        $(obj).parents('.b-group').eq(0).find("input[type='checkbox']").prop('checked', $(obj).prop('checked'));
    }
</script>
<style type="text/css">
    .table {margin-bottom:0;}
    label{margin-left: 10px;}
</style>